package com.glodon.paas.framework.registry.server.resource;

import com.glodon.paas.framework.registry.core.type.ServiceDetail;
import com.glodon.paas.framework.registry.server.ServerManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import java.util.List;

/**
 * @author Don Li
 */
@Service
@Path("/discover/services")
public class ServiceResource {
    @Autowired
    private ServerManager serverManager;

    @GET
    @Produces("application/json")
    public List<String> getAllServiceId() {
        return serverManager.listAllServices();
    }

    @Path("/{serviceId}")
    @GET
    @Produces("application/json")
    public ServiceDetail getServiceDetail(@PathParam("serviceId") String serviceId) {
        return serverManager.getServiceDetail(serviceId);
    }
}
